#pragma once

#include "ExecutionOccurrenceSpecification.h"

#include "ExecutionSpecification.h"

namespace uml {

ExecutionOccurrenceSpecification::ExecutionOccurrenceSpecification(const QString& umlType)
    : OccurrenceSpecification(umlType) {}

void ExecutionOccurrenceSpecification::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    OccurrenceSpecification::fromJson(json, errorList);
    execution_ = JsonSerializable::create<ExecutionSpecification>(json.value("execution"), errorList);

}

void ExecutionOccurrenceSpecification::toJson(QJsonObject& json) {
    OccurrenceSpecification::toJson(json);
    if (execution_) {
        QJsonObject execution_json;
        execution_->toJson(execution_json);
        json.insert("execution", execution_json);
    }
}

/// <summary>
/// execution getter
/// References the execution specification describing the execution that is started
/// or finished at this execution event.
/// </summary>
shared_ptr<ExecutionSpecification> ExecutionOccurrenceSpecification::execution() const {
    return execution_;
}

/// <summary>
/// execution setter
/// References the execution specification describing the execution that is started
/// or finished at this execution event.
/// </summary>
void ExecutionOccurrenceSpecification::setExecution(shared_ptr<ExecutionSpecification> value) {
    execution_ = value;
}

} // namespace uml
